package com.ty.day7;

import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * Author : txy
 * Create 2023/11/3 16:40
 */
public class Five {
    public static void main(String[] args) {
        int[] a = new int[13];
        for (int i = 0; i < a.length; i++) {
            a[i] = i + 1;
        }
        System.out.println(Arrays.toString(a));
        int l = 0, i = 0, len = a.length;
        while (len > 1) {

            if (a[i] != 0) {//只要不为0代表还有游戏资格
                l = l + 1;
                System.out.println(a[i] + "报数：" + l);//这个人报数
                if (l % 3 == 0) {//但是如果这个人是3号，则失去游戏资格
                    a[i] = 0;
                    len = len - 1;//游戏人数减少一个
                    l = 0;//计数重新开始
                }
            }
            i++;
            if (i == a.length) {
                i = 0;
            }
        }
        for (int j : a) {
            if (j != 0) {
                System.out.println("幸存者：" + j);
                break;
            }
        }
    }
}
